const sequelize = require("./db");
const { DataTypes } = require("sequelize");

//工程师 level: 5、超级管理员level:1、管理员level:2、用户level:0
module.exports = sequelize.define(
  "user",
  {
    id: {
      type: DataTypes.UUID,
      primaryKey: true,
      allowNull: false,
    },
    username: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    passwd: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    level: {
      type: DataTypes.INTEGER,
      allowNull: false,
    },
    name: {
      type: DataTypes.STRING,
    },
    tel: {
      type: DataTypes.STRING,
    },
    email: {
      type: DataTypes.STRING,
    },
    sign: {
      type: DataTypes.STRING,
    },
    intelligent: {
      type: DataTypes.INTEGER,
    },
    currentToken: {
      type: DataTypes.STRING,
    },
  },
  {
    freezeTableName: true,
    indexes: [{ unique: true, fields: ["username"] }],
  }
);
